package com.xindz.hgq.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

import com.blankj.utilcode.util.ToastUtils;
import com.xindz.hgq.R;
import com.xindz.hgq.activity.MvpPresenter;
import com.xindz.hgq.activity.MvpView;
import com.xindz.hgq.base.BaseFragment;
import com.xindz.hgq.base.BasePresenter;
import com.xindz.hgq.base.BaseView;
import com.xindz.hgq.base.MvpInterface;
import com.xindz.hgq.base.options.BaseFragmentOptions;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * @name HGQBase
 * @class name：com.xindz.hgq.fragment
 * @describe describe
 * @anthor XINDZ
 * @time 2018/1/16 13:15
 * @change
 * @chang time
 * @class describe
 */
public class MvpFragment extends BaseFragment<MvpView, MvpPresenter> implements MvpView, MvpInterface {
    @BindView(R.id.bt_frag_show)
    Button btFragShow;
    Unbinder unbinder;

    @Override
    public BaseFragmentOptions setOption() {
        return new BaseFragmentOptions().openMVP(this);
    }

    @Override
    public int onCreateFragmentLayoutId() {
        return R.layout.fragment_frag_default;
    }

    @Override
    public BasePresenter createPresneter() {
        return new MvpPresenter();
    }

    @Override
    public BaseView createView() {
        return this;
    }

    @Override
    public void showToase(String msg) {
        ToastUtils.showShort(msg);

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // TODO: inflate a fragment view
        View rootView = super.onCreateView(inflater, container, savedInstanceState);
        unbinder = ButterKnife.bind(this, rootView);
        return rootView;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }

    @OnClick(R.id.bt_frag_show)
    public void onViewClicked() {
        getPresneter().showToast("MVP   SHOW");
    }
}
